<?php
//       PHPcongrats - Holiday and Birthday Mailer
//     
//    Copyright (C) 2011  Matthias Nass
//
//    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
session_start();
if ($_SESSION['loggedin'] == true){
        $id =  (int) $_GET['id'];
        include 'DBconnect.php';
        include 'datefunction.php';
        $query = "SELECT * FROM text WHERE id=".$id.";";
        $query_holi = "SELECT * FROM holidays ;";
        $result = mysql_db_query($database, $query, $link);
        $result_holi = mysql_db_query($database, $query_holi, $link);
        $row = mysql_fetch_row($result);
        mysql_close($link);
     	?>
     <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
     <html>
     <head>
     <title>Text &auml;ndern</title>
     <link rel="stylesheet" type="text/css" href="./styles.css">
     </head>
     <body>
     	<h2>PHPcongrats <img src='./icons/rosette.png' alt='Rosette'/></h2>
     	<h1>Text &auml;ndern <img src='./icons/note_edit.png' alt='edit note'/></h1>
     	<p class="message">
     	<?php if($_SESSION['message'] == ''){}else{?>
     	<img src='./icons/error.png' alt='attention'/> <?php echo $_SESSION['message']; }?>
     	</p>
     	<form action="./actionchatext.php" method="post">
     		<input type="hidden" name="id" value=<?php echo $id;?> />
     		<input type="text" name="name" value=<?php echo $row[2];?>> Name<br>
     		<select name="holiday_id">
     		<?php while($row_holi = mysql_fetch_row($result_holi))
     		      if ($row[1]==$row_holi[0]){
     		           echo "<option value='".$row_holi[0]."' selected>".$row_holi[1]."</option>";
     		      }else{
     		           echo "<option value='".$row_holi[0]."'>".$row_holi[1]."</option>";
     		      }
     		?>
     		<select name="count">
     		<?php 
     		$count=1;
     		while($count<20){
     		   if($row[7]==$count){
     		        echo "<option value='".$count."' selected>".$count."</option>";
     		   }else{
     		        echo "<option value='".$count."'>".$count."</option>";
     		   }
     		   $count++;
     		}
     		?>
     		
     		</select><br />
     		</select><br />
     		<input type="text" name="lang" value=<?php echo $row[3];?>> Sprache<br />
     		<textarea  class="textfieldtext" name="text" '> <?php echo $row[4];?></textarea>Text<br />     		
     		<input type="submit" name="submit"><br>
     	</form>
     	<p>
     		<a href="./text.php"><img src='./icons/cross.png' alt='Cancel'/> Abbrechen</a>
     	</p>
     </body>
     </html>
     	<?php
     	$_SESSION['message'] = "";
}
else{
    $_SESSION['last_location'] = "./text.php";
	header( 'Location: http:./login.php' );
}
?>